This invention relates generally to file systems operating in a transaction environment, and more particularly to implementing file system transactions using a state-based scheme.
A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever. The following notice applies to the software and data as described below and in the drawing hereto: Copyright(copyright) 1997, Microsoft Corporation, All Rights Reserved.
File systems in transaction-oriented environments support transactions performed against the components of the file system, i.e., the directories and files. The components make up the namespace of the file system.
Transaction-oriented file systems usually maintain a log of changes made to the names in the namespace and write the changes to persistent storage when the transaction commits the changes. Current file systems use a time-based list as the log and record each and every name change made in the namespace in chronological order so that the changes can be applied when the modifying transaction commits.
However, when more than one change is made to the same namespace component before the changes are committed, only the final change is of interest and using space to store the intermediate changes in the log is wasteful. Additionally, applying the intermediate changes in chronological order when the transaction commits is usually unnecessary and slows the performance of the file system.
Therefore, a way is needed to collapse the unnecessary intermediate changes into a final state for the file system namespace and to apply the final state to each component in the namespace.
The above-mentioned shortcomings, disadvantages and problems are addressed by the present invention, which will be understood by reading and studying the following specification.
State-based offspring objects are created to correspond to each object in a file system namespace when the corresponding object is opened. Each offspring object contains two fields, an original name field containing the name of the object when opened and a final name field. Each change made to the object is written to the final name field so that the final name field always reflects the last change made to the name of the object. The various combinations of the fields define the offspring object""s state. The offspring objects are arranged in a hierarchical structure that mimics the structure of the namespace with the offspring object corresponding to the top level open object as its root. When the changes are committed, the state of the offspring object is used to determine the correct operation to be performed on the corresponding object. Once the commit completes, the final name is written into the original name field. If changes are aborted, the original name is written into the final name field.
In one aspect of the invention, the final names for objects at intermediate levels in the namespace hierarchy are written to memory when the changes are committed and only written to the file system""s persistent storage when a commit is made at the top level open object. In another aspect of the invention, a temporary offspring object is created to accommodate a circular rename transaction.
Because an offspring object needs only the original and final name fields to define the state of a file system object and maintains only the last state of the object, the offspring objects of the present invention are less wasteful of memory space than the time-based log of the previous file system implementations. Additionally, a file system that uses the offspring objects of the present invention applies only the final state of the offspring object to the object, thus saving processing time. Special situations that require applying intermediate changes to the object are also implemented using the offspring objects so no special object types need be created.
The present invention can be practiced in a non-object-based file system using any data structure that incorporates the characteristics detailed above for the offspring object. Furthermore, the invention is applicable to file formats which support a hierarchical arrangement of data within a file that mimics a traditional file system.